package ch.fhnw.qualiscan.api.output;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import ch.fhnw.qualiscan.core.db.pojos.BestPractice;

@XmlRootElement
@XmlType(propOrder = {"link", "bestPractice"})
public class BestPracticesOutput {
	
	List<BestPracticeOutput> bestPractices;
	List<BestPractice> entities;
	List<LinkOutput> links;
	
	URI uri;

	public BestPracticesOutput() {}
	
	public BestPracticesOutput(List<BestPractice> bpList, List<LinkOutput> links) {
        this.entities = bpList;
        this.links = links;
    }
	
	@XmlElementWrapper(name="links")
    public List<LinkOutput> getLink() {
        return links;
    }

    public void setLink(List<LinkOutput> links) {
        if(links != null)
            this.links = links;
    }
	
	@XmlElementWrapper(name="bestpractices")
	@XmlElement(name = "bestpractice")
    public List<BestPracticeOutput> getBestPractice() {
        if(bestPractices == null) {
        	bestPractices = new ArrayList<BestPracticeOutput>();
        }
        
        if (entities != null) {
            for (BestPractice bp : entities) {
            	bestPractices.add(new BestPracticeOutput(bp));
            }
        }

        return bestPractices;
    }

}
